Skip to content

Conversation

@stuartmorgan-g
Copy link
Collaborator

Replaces the Obj-C example app with Swift. Rather than attempt to modify the example in place, I started clean from the Swift template:

  • deleted the ios/ directory.
  • ran flutter create --platforms=ios . using current stable (3.41.0).
  • re-did the RunnerUITest setup process, and swapped in the existing test files for that and RunnerTest.
  • ran native tests and the example app to capture the auto-migration steps for CocoaPods.

In addition, I did some cleanup on the Dart part of this example, which had never been updated post-federation (since implementation package example apps are mostly not things we expect users to look at, so it's never been a priority):

  • Removed the canLaunch/launch anti-pattern, which was long since removed from the app-facing package. This copies the code from app-facing example to demonstrate canLaunch controlling enabling a UI element, which is how we recommend using it.
  • Removed all the configuration options that only ever worked on Android, since they are't relevant to an iOS example.

Pre-Review Checklist

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self];
[super application:application didFinishLaunchingWithOptions:launchOptions];
return YES;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike the quick_actions case I could not find any good reason for this behavior. Unlike quick_actions it wasn't added later, but was just part of the very first url_launcher checkin, and I think of any reason this would be relevant for url_launcher testing, so I didn't replicate this into the Swift version, and just stuck with the standard template code.

let app = self.app!

let buttonNames: [String] = [
"Launch in app", "Launch in app(JavaScript ON)", "Launch in app(DOM storage ON)",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed because they are no longer in the example app, because these options do nothing on iOS.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modernizes the url_launcher_ios example application, migrating the native iOS part from Objective-C to Swift and updating the Dart code to use the latest url_launcher APIs, such as launchUrl with LaunchOptions, while also demonstrating capability checks. A medium-severity vulnerability was identified where unsanitized user input is used to construct a tel: URI, which could lead to unintended behavior.

Copy link
Contributor

@LongCatIsLooong LongCatIsLooong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

import UIKit

@main
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is the @objc attribute needed? FlutterAppDelegate is already an objc class I think? Also the didFinishLaunchingWithOptions method doesn't seem to be overriding anything?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal here is to only deviate from the template when there's a plugin-specific reason to. I don't know why the template is this way (the second may well just be leftover from when plugin registration was in that method), but that would be something to change in the template itself rather than here.

} else {
throw Exception('Could not launch $url');
}
launcher.canLaunch('tel://123').then((bool result) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a mounted check in case the future resolves after the widget is disposed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, done!

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 12, 2026
@auto-submit auto-submit bot merged commit 9cac057 into flutter:main Feb 12, 2026
81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App p: url_launcher platform-ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants